<?php
class ImageDLPlugin {
    var $ld;
    var $bot;
    var $np;
    var $XMLconfig;
    // ==========================================================================
    function ImageDLPlugin()
    {
        $this->ld = new LocalData();
        $this->bot = new Bot();
    }
    // ==========================================================================
	function GetForm($server)
	{
		$PlVersion = (array)$this->ld->GetPlVersion('ImageDL');
		$imagePath = substr($_SERVER["PHP_SELF"], 0, strpos($_SERVER["PHP_SELF"], "/"));

		echo '
		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">
			<head>
				<title>Multi helper</title>
				<script src="..\..\codebase-php\jquery-1.4.2.min.js"></script>
				<script src="..\..\codebase-php\jquery.json-2.2.min.js"></script>
				<link href="helpers/menu.css" rel="stylesheet" type="text/css">
				<link href="helpers/plugin.css" rel="stylesheet" type="text/css">
				<script type="text/javascript" src="helpers/menu.js"></script>
				<script>
				//======================================================================
					$(document).ready(function(){
						$("#btn_rst_image").click(function(){
							var req=new Object();
							//$(":checkbox").each(function(){  var par=$(this).attr("id");  req[par]=$(this).attr("checked");   });
							req["reset"]=$("#reset").val();
							data=$.toJSON(req);
							var l=window.location.toString();
							var indx=l.indexOf(\'?\');
							var nurl=l.slice(0, indx)+"?action=btn_rst_image&tmp="+Math.random();
							$.post(nurl, data);
							return false;
						});
					}); // end document ready
				</script>
			</head>
			<body>
				<hr>
				<h1>ImageDL (by Little Todd) Version '.$PlVersion['version'].' ('.$PlVersion['date'].') </h1>
				<h2>Code from the Multi Plugin created by 12Christiaan</h2>
				<hr>
				This Plugin downloads images for use by other plugins.<br><br>
				Nothing is required except to have this plugin active.<br><br>
				Normaly the images are downloaded automatically, but if for some reason not all the images are available, press the Reset Images Button below.<br><br>
				When the reset button is pressed, the next time the bot runs, it will check all the images and try to download any missing.<br><br>
				You only have to press 1 time<br>
				<form>
					<input id="reset" type="hidden" value="10" size="4">
					<div width="100%" align="center">
					<button id="btn_rst_image" style="color:white;background-color:#13a89e;border-width:1px;border-style:solid; ">&nbsp; Reset Images &nbsp;</button>
					</div>
				</form>
				<hr>
				<center><h2>Latest Images Downloaded</h2></center><br>';
		$res = ($this->ld->GetSelect('SELECT count(*) as cnt FROM sqlite_master where tbl_name="LatestImages"'));
		if ($res[0]["cnt"] > 0)
		{
			$DBimage = $this->ld->GetSelect("SELECT * FROM LatestImages");
			foreach ($DBimage as $images)
			{
				echo '
				<div style="	background-color: white;
								overflow: hidden;
								cursor: pointer;
								border: 1px solid #000;
								text-align: center;
								width: 225px;
								height: 120px;
								max-height: 120px;
								margin: 5px;
								padding: 5px;
								float: left;">
					<span style="	font-weight: bold;
									display: block;
									height: 22px;"
									>'. $images['ItemName'] .'</span>
					<img style="	display: block;
									height: 80px;"
									src="'. $imagePath . $images['url'] .'">
				</div>';
			}
			echo '
				<br><br><br><br><br><br><br><br><br>
				<hr>';
		}
		echo '
			</body>
		</html>';
	}
}

?>


